package com.yunshipei.common.net.api;

import com.yunshipei.model.AppConfigModel;
import com.yunshipei.model.CollectionData;
import com.yunshipei.model.FrequentContacts;

import org.json.JSONObject;

import java.util.Map;

import io.reactivex.Flowable;
import okhttp3.RequestBody;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PartMap;
import retrofit2.http.Url;

public interface InterfaceApi {

    @FormUrlEncoded
    @POST("/v2/changepwd")
    Flowable<JSONObject> modifyPassword(@Field("uuid") String uuid, @Field("password") String password);

    @FormUrlEncoded
    @POST("/v2/checkApkVersion")
    Flowable<JSONObject> checkUpdate(@Field("companyId") String companyID);

    @FormUrlEncoded
    @POST("/v2/checkIn")
    Flowable<JSONObject> checkIn(@Field("beaconUuid") String beaconUuid, @Field("beaconMajor") String major, @Field("beaconMinor") String minor, @Field("companyId") String companyId, @Field("username") String name);

    @FormUrlEncoded
    @POST("/v2/group")
    Flowable<JSONObject> fetchGroupById(@Field("gid") String gid);

    @FormUrlEncoded
    @POST("/departmentmembers")
    Flowable<FrequentContacts> fetchDepartment(@Field("id") String id, @Field("companyId") String cid);

    @FormUrlEncoded
    @POST
    Flowable<JSONObject> retrievePassword(@Url String url, @FieldMap Map<String, String> map);

    @FormUrlEncoded
    @POST("/v2/groups")
    Flowable<JSONObject> reFetchGroupInfo(@Field("id") String id);

    @FormUrlEncoded
    @POST("/all")
    Flowable<FrequentContacts> fetchContactsList(@Field("companyId") String cid, @Field("uuid") String uuid, @Field("password") String password);

    @FormUrlEncoded
    @POST("/v2/getToken")
    Flowable<JSONObject> reFetchToken(@Field("uuid") String uuid);

    @FormUrlEncoded
    @POST("/v2/getCode")
    Flowable<JSONObject> fetchReCaptcha(@Field("uuid") String uuid, @Field("byWhich") String content);

    @FormUrlEncoded
    @POST
    Flowable<JSONObject> fetchIMContacts(@Url String url, @FieldMap Map<String, String> map);

    @FormUrlEncoded
    @POST("/v2/addgroup")
    Flowable<JSONObject> addIMGroupMembers(@Field("id") String id, @Field("name") String name, @Field("cids") String cIds);

    @FormUrlEncoded
    @POST("/v2/joingroup")
    Flowable<JSONObject> makeIMGroup(@Field("cids") String cid, @Field("gid") String gid);

    @FormUrlEncoded
    @POST("/v2/quitgroup")
    Flowable<JSONObject> exitIMGroup(@Field("isActive") boolean isActive, @Field("companyId") String companyId, @Field("uuid") String uuid, @Field("gid") String gid);

    @FormUrlEncoded
    @POST("/v2/newQuitGroup")
    Flowable<JSONObject> newExitIMGroup(@Field("isActive") boolean isActive, @Field("companyId") String companyId, @Field("uuids[]") String[] uuid, @Field("gid") String gid);

    @Multipart
    @POST("/v2/editGroup")
    Flowable<JSONObject> modifyIMGroupAvatar(@PartMap Map<String, RequestBody> map);

    @Multipart
    @POST("/v2/imgupload")
    Flowable<JSONObject> modifyPersonalAvatar(@PartMap Map<String, RequestBody> map);

    @FormUrlEncoded
    @POST("/v2/editGroup")
    Flowable<JSONObject> modifyGroupName(@Field("gid") String gid, @Field("name") String name);

    @FormUrlEncoded
    @POST("/V2/addGroupByDepId")
    Flowable<JSONObject> addGroupByDepId(@Field("did") String did, @Field("uuid") String uuid, @Field("cid") String cid, @Field("name") String name);

    @FormUrlEncoded
    @POST("/v2/showup")
    Flowable<JSONObject> processRestart(@Field("companyId") String companyId, @Field("name") String name, @Field("uuid") String uuid);

    @FormUrlEncoded
    @POST("/u/addColleague")
    Flowable<JSONObject> addColleague(@Field("uuid") String uuid, @Field("targetUuid") String targetUuid, @Field("cid") String cid);

    @FormUrlEncoded
    @POST("/u/deleteColleague")
    Flowable<JSONObject> deleteColleague(@Field("uuid") String uuid, @Field("targetUuid") String targetUuid, @Field("cid") String cid);

    // 获取常用联系人列表
    @FormUrlEncoded
    @POST("/u/colleagues")
    Flowable<FrequentContacts> getColleagues(@Field("companyId") String companyId, @Field("uuid") String uuid, @Field("departmentId") String departmentId);

    // 上传文件
    @Multipart
    @POST
    Flowable<JSONObject> uploadFile(@Url String url, @PartMap Map<String, RequestBody> map);

    @FormUrlEncoded
    @POST("/v2/getUserInfo")
    Flowable<JSONObject> getUserInfo(@Field("companyId") String companyId, @Field("uuid") String uuid);


    //添加收藏
    @FormUrlEncoded
    @POST("/v2/addCollection")
    Flowable<JSONObject> addCollection(@Field("companyId") String companyId, @Field("uuid") String uuid, @Field("item") String collectionItem);


    //取消收藏
    @FormUrlEncoded
    @POST("/v2/deleteCollection")
    Flowable<JSONObject> deleteCollection(@Field("companyId") String companyId, @Field("uuid") String uuid, @Field("item") String collectionItem);

    //获取收藏的内容
    @FormUrlEncoded
    @POST("/v2/collections")
    Flowable<CollectionData> getCollectionList(@Field("companyId") String companyId, @Field("uuid") String uuid);

    //发送地理位置到manager
    @FormUrlEncoded
    @POST("/v2/position")
    Flowable<JSONObject> sendLocation(@Field("deviceId") String devicesID, @Field("position") String location);

    //埋点统计
    @FormUrlEncoded
    @POST("/v2/addstatistics")
    Flowable<JSONObject> statisticData(@Field("sobj") String data);

    //水印设置接口
    @FormUrlEncoded
    @POST("/v2/getSetting")
    Flowable<AppConfigModel> getSetting(@Field("companyId") String companyId);

    //获取token的接口
    @FormUrlEncoded
    @POST("/u/ssos/token")
    Flowable<JSONObject> getSingleSign(@Field("companyId") String companyId, @Field("uuid") String userName, @Field("password") String password);
}
